package com.youxin.sql.commonApi;

import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.java.BatchTableEnvironment;
import org.apache.flink.table.sources.CsvTableSource;

public class RegisterATable {
    public static void main(String[] args) {
        ExecutionEnvironment fbEnv = ExecutionEnvironment.getExecutionEnvironment();
        BatchTableEnvironment fbTableEnv = BatchTableEnvironment.create(fbEnv);

        // register the table projTable as table "projectedTable"
        Table scan = fbTableEnv.scan("s", "a");//.select();
        fbTableEnv.registerTable("projectedTable",scan);

        // create a tableSource
        TypeInformation[] objectTypeInformation = {Types.STRING};
        CsvTableSource csvTableSource = new CsvTableSource("path", new String[]{""}, objectTypeInformation);
        fbTableEnv.registerTableSource("csvTableSource",csvTableSource);


        // create a tableSink



        Table table = fbTableEnv.sqlQuery("select * from projectedTable");



    }
}
